package com.example.springbootjackson.traceId;

import com.example.springbootjackson.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
@Slf4j
public class ApiExceptionHandler {

//    @ResponseStatus(HttpStatus.OK)
    @ExceptionHandler(value = Exception.class)
    public Response allExceptionHandler(HttpServletRequest request,
                                        Exception exception) {
        log.error("allExceptionHandler  e={}",exception.toString());
        Response response = new Response();
        response.setCode(500);
        response.setMsg(exception.toString());
        return response;

    }

}
